package com.monitor.zk.zookeeper.command;

import cn.hutool.system.SystemUtil;

public class ExecCommandFactory {

    private static LinuxSystemInfoCommand linuxSystemInfoCommand;
    private static LinuxProjectInfoCommand linuxProjectInfoCommand;
    private static VMInfoCommand vmInfoCommand;

    public static LinuxSystemInfoCommand getLinuxSystemInfoCommand()throws RuntimeException{
        if(linuxSystemInfoCommand != null){
            return linuxSystemInfoCommand;
        }
        checkSystemOs();
        linuxSystemInfoCommand = new LinuxSystemInfoCommand();
        return linuxSystemInfoCommand;
    }

    public static LinuxProjectInfoCommand getLinuxProjectInfoCommand()throws RuntimeException{
        if(linuxProjectInfoCommand != null){
            return linuxProjectInfoCommand;
        }
        checkSystemOs();
        linuxProjectInfoCommand = new LinuxProjectInfoCommand();
        return linuxProjectInfoCommand;
    }

    public static VMInfoCommand getVmInfoCommand() throws RuntimeException{
        if(vmInfoCommand != null){
            return vmInfoCommand;
        }
        checkSystemOs();
        vmInfoCommand = new VMInfoCommand();
        return vmInfoCommand;
    }

    private static void checkSystemOs() throws RuntimeException{
//        if(!SystemUtil.getOsInfo().isLinux()){
//            throw new RuntimeException("非linux机器，无法执行");
//        }
    }


}
